<?php

/**
 * News Content Model
 * @author PhuND
 */
class Mnews_content extends CI_Model {

    private $tableName = 'news_content';

    public function __construct() {
        parent::__construct();
        $this->load->database();
    }

    /**
     * Get News Content by ID
     * @param int $id
     * @return row
     */
    public function getByID($id) {
        $this->db->cache_on();
        $this->db->select();
        $this->db->where("id", $id);
        $query = $this->db->get($this->tableName);
        return $query->row();
    }

    public function getTopNew($row_count, $offset = 0) {
        $this->db->cache_on();
        $this->db->select("id, title, lead");
        $this->db->where("status", 1);
        $this->db->limit($row_count, $offset);
        $this->db->order_by("id desc");
        $query = $this->db->get($this->tableName);
        return $query->result_array();
    }

}